/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hit.core;

import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;

public class ProductGroupTest {

	private ProductGroup testGroup1, testGroup2;
	
    public ProductGroupTest() {
    }

    @Before
    public void setUp() {
		testGroup1 = new ProductGroup("Test Group 1");
		testGroup2 = new ProductGroup("Test Group 2");
    }

	@Test
	public void testGetParentContainer() {
		testGroup1.SetParentContainer(testGroup2);
		assertEquals(testGroup2, testGroup1.GetParentContainer());
	}

	@Test
	public void testSetParentContainer() {
		try{
			testGroup1.SetParentContainer(null);
			fail("Incorrectly able to set parent container to null.");
		}
		catch (IllegalArgumentException e){}
		
		try{
			testGroup1.SetParentContainer(testGroup2);
		}
		catch (IllegalArgumentException e){
			fail("Unable to set parent container.");
		}
	}

	@Test
	public void testGetThreeMonth() {
		Size expResult = new Size();
		testGroup1.SetThreeMonth(expResult);
		assertEquals(expResult, testGroup1.GetThreeMonth());
	}

	@Test
	public void testSetThreeMonth() {
		try{
			testGroup1.SetThreeMonth(null);
			fail("Incorrectly able to set threeMonth to null.");
		}
		catch (IllegalArgumentException e){}
		
		try{
			testGroup1.SetThreeMonth(new Size());
		}
		catch (IllegalArgumentException e){
			fail("Unable to set threeMonth.");
		}
	}

	@Test
	public void testIsValid() {
		assertFalse("Product Group 2 is valid, when it shouldn't be", testGroup2.IsValid());
		
		testGroup1.SetThreeMonth(new Size());
		testGroup1.SetParentContainer(testGroup2);
		assertTrue("Product Group 1 IsValid() failed", testGroup1.IsValid());
	}

}